package com.itheima.module.service.impl;

import com.itheima.module.dao.UserDao;
import com.itheima.module.pojo.User;
import com.itheima.module.service.UserService;
import org.apache.ibatis.session.SqlSession;
import org.apache.ibatis.session.SqlSessionFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

import java.util.ArrayList;
import java.util.Date;
import java.util.List;

@Service
@Transactional
public class UserServiceImpl implements UserService {
    @Autowired
    private UserDao userDao;
    //@Autowired
    //private SqlSessionFactory sqlSessionFactory;
    @Override
    @Transactional
    public List<User> findAll() {
        //System.out.println("获取到了"+sqlSessionFactory);
        /*SqlSession sqlSession = sqlSessionFactory.openSession();
        try {
            UserDao userDao = sqlSession.getMapper(UserDao.class);
            List<User> users = userDao.findAll();
            return users;
        }finally {
            sqlSession.close();
        }*/

        return userDao.findAll();
    }
}
